/*
 * 23/10/2011 - 16:49
 */
package org.nettyflux.netmessages;

import org.nettyflux.communicator.RemoteHost;

/**
 * @author Victor Williams Stafusa da Silva
 */
public final class SendCommand<R extends RemoteHost> implements NetworkMessage {

    private final byte[] message;
    private final R receiver;

    public SendCommand(R receiver, byte[] message) {
        this.message = message;
        this.receiver = receiver;
    }

    public static <R extends RemoteHost> SendCommand<R> create(R receiver, byte[] message) {
        return new SendCommand<R>(receiver, message);
    }

    public byte[] getMessage() {
        return message;
    }

    public R getReceiver() {
        return receiver;
    }

    public Ack<SendCommand<R>> makeAck() {
        return new Ack<SendCommand<R>>(this);
    }

    public FailAck<SendCommand<R>> makeFailAck(Throwable badNews) {
        return new FailAck<SendCommand<R>>(this, badNews);
    }
}
